namespace DataModels.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class EID : DbMigration
    {
        public override void Up()
        {
            CreateTable(
                "dbo.AssociatedEarlyInfantDiagnosis",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        FacilityCode = c.String(nullable: false, maxLength: 50, unicode: false),
                        TimeframeId = c.Int(nullable: false),
                        CounselingAndTestingId = c.Int(nullable: false),
                        CreatedByUserId = c.Int(nullable: false),
                        DateCreated = c.DateTime(nullable: false),
                        UpdatedByUserId = c.Int(),
                        UpdateDate = c.DateTime(),
                        MC10_Female = c.Int(nullable: false),
                        MC10_Male = c.Int(nullable: false),
                        MC11_Female = c.Int(nullable: false),
                        MC11_Male = c.Int(nullable: false),
                        MC12_Female = c.Int(nullable: false),
                        MC12_Male = c.Int(nullable: false),
                        MC13_Female = c.Int(nullable: false),
                        MC13_Male = c.Int(nullable: false),
                        MC14_Female = c.Int(nullable: false),
                        MC14_Male = c.Int(nullable: false),
                        MC15_Female = c.Int(nullable: false),
                        MC15_Male = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.TestingAndCounselings", t => t.CounselingAndTestingId, cascadeDelete: true)
                .ForeignKey("dbo.Users", t => t.CreatedByUserId, cascadeDelete: true)
                .ForeignKey("dbo.Facilities", t => t.FacilityCode, cascadeDelete: true)
                .ForeignKey("dbo.Timeframes", t => t.TimeframeId, cascadeDelete: true)
                .ForeignKey("dbo.Users", t => t.UpdatedByUserId)
                .Index(t => t.FacilityCode)
                .Index(t => t.TimeframeId)
                .Index(t => t.CounselingAndTestingId)
                .Index(t => t.CreatedByUserId)
                .Index(t => t.UpdatedByUserId);
            
        }
        
        public override void Down()
        {
            DropForeignKey("dbo.AssociatedEarlyInfantDiagnosis", "UpdatedByUserId", "dbo.Users");
            DropForeignKey("dbo.AssociatedEarlyInfantDiagnosis", "TimeframeId", "dbo.Timeframes");
            DropForeignKey("dbo.AssociatedEarlyInfantDiagnosis", "FacilityCode", "dbo.Facilities");
            DropForeignKey("dbo.AssociatedEarlyInfantDiagnosis", "CreatedByUserId", "dbo.Users");
            DropForeignKey("dbo.AssociatedEarlyInfantDiagnosis", "CounselingAndTestingId", "dbo.TestingAndCounselings");
            DropIndex("dbo.AssociatedEarlyInfantDiagnosis", new[] { "UpdatedByUserId" });
            DropIndex("dbo.AssociatedEarlyInfantDiagnosis", new[] { "CreatedByUserId" });
            DropIndex("dbo.AssociatedEarlyInfantDiagnosis", new[] { "CounselingAndTestingId" });
            DropIndex("dbo.AssociatedEarlyInfantDiagnosis", new[] { "TimeframeId" });
            DropIndex("dbo.AssociatedEarlyInfantDiagnosis", new[] { "FacilityCode" });
            DropTable("dbo.AssociatedEarlyInfantDiagnosis");
        }
    }
}
